package Client.PokerClient.src;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 * Listener Klasy ServerConnection.
 * @author Smolibowski Artur
 */
public class ServerConnectionListener implements ActionListener {
  /**
   * Referencja do klasy glownej.
   */
  private Client client;
  /**
   * Klasa nasluchiwana.
   */
  private ServerConnectionWindow serverConectionWindow;
  /**
   * Konstruktor klasy.
   * @param client Referencja do klasy glownej.
   * @param serverConectionWindow Klasa nasluchiwana.
   */
  ServerConnectionListener(Client client, ServerConnectionWindow serverConectionWindow) {
    this.client=client;
    this.serverConectionWindow=serverConectionWindow;
  }
  /**
   * Metoda zajmujaca sie zdarzeniami wystepujacymi w klasie ServerConnectionWindow.
   */
  public void actionPerformed(ActionEvent e) {
    if(e.getSource() == serverConectionWindow.getPolacz()) {
      client.getGameThread().ConnectToServer(serverConectionWindow.getSerAdr().getText(), serverConectionWindow.getPort().getText());
    }
	if(e.getSource() == serverConectionWindow.getBack()) {
      client.getMenuWindow().ChangeWindow();;
    }
  }
}
